import axios from '@/util/request'
import store from '@/store/index'
// 获取评论内容
const getComments = (params) => {
  return axios.get(`/public/comments`, {
    params,
    headers: {
      Authorization: `Bearer ${store.state.token}`
    }
  })
}

// 添加评论
const addComment = (data) => {
  return axios.post('/comments/reply', data)
}

// 更新评论
const updateComment = (data) => {
  return axios.put('/comments/reply', data)
}

// 设置最佳
const setBestComment = (data) => {
  return axios.post('/comments/best', data)
}

// 点赞
const addHands = (data) => {
  return axios.post('/comments/hands', data)
}

// 获取用户评论内容
const getUserComments = (params) => {
  return axios.get(`/public/user/comments`, {
    params
  })
}
export {
  getComments,
  addComment,
  updateComment,
  setBestComment,
  addHands,
  getUserComments
}
